﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;

namespace online_magazine1.Models
{
    public class SampleData:DropCreateDatabaseIfModelChanges<MagazineEntities>
    {
        protected override void Seed(MagazineEntities context)
        {
            var themes = new List<Theme>{
                new Theme {ThemeName = "Phisics"},
                new Theme {ThemeName = "Math"},
                new Theme {ThemeName = "Literature"},
                new Theme {ThemeName = "Music"}
            };
            themes.ForEach(th => context.Themes.Add(th));
            new List<Article>{
                new Article {AuthorId = "anonymous", DateCreated = System.DateTime.Now, Title ="Mozart's biography", MainText = "Mozart was born sometime...", Description = "About Mozarts life", FileUrl = "", Theme = themes.Single(th=>th.ThemeName == "Music")},
                //new Article {AuthorId = "anonymous", DateCreated = System.DateTime.Now, Title ="Evklid's biography", MainText = "Mozart was born sometime...", Description = "About Mozarts life", FileUrl = "", Theme = themes.Single(th=>th.ThemeName == "Math")},
                //new Article {AuthorId = "anonymous", DateCreated = System.DateTime.Now, Title ="Einstein's biography", MainText = "Mozart was born sometime...", Description = "About Mozarts life", FileUrl = "", Theme = themes.Single(th=>th.ThemeName == "Phisics")},
                //new Article {AuthorId = "anonymous", DateCreated = System.DateTime.Now, Title ="Jack London's biography", MainText = "Mozart was born sometime...", Description = "About Mozarts life", FileUrl = "", Theme = themes.Single(th=>th.ThemeName == "Literature")}
            }.ForEach(a => context.Articles.Add(a));
        }
    }
}